/**
 * @description localStorage 方法封装
 */

function setItem(key, value) {
  value = JSON.stringify(value)
  window.localStorage.setItem(key, value)
}

function getItem(key) {
  const value = window.localStorage.getItem(key)
  try {
    return JSON.parse(value)
  } catch (ex) {
    return value
  }
}

function removeItem(key) {
  window.localStorage.removeItem(key)
}

export default {
  setItem,
  getItem,
  removeItem
}